Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new switch to allow inclusion of all class teams #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JorgeRaastroem
Copy link

No description provided.

@ghost
Copy link

ghost commented Aug 15, 2020

CLA assistant check
All CLA requirements met.

function Get-SDSTeams($logFilePath) {
$initialSDSGroupUri = "https://graph.microsoft.com/beta/groups?`$filter=groupTypes/any(c:c+eq+'Unified')+and+startswith(mailNickname,'Section_')+and+resourceProvisioningOptions/Any(x:x+eq+'Team')&$groupSelectClause"
function Get-SDSTeams($IncludeNonSDSGroups, $logFilePath) {
$initialSDSGroupUri = "https://graph.microsoft.com/beta/groups?`$filter=groupTypes/any(c:c+eq+'Unified')" + $(if(-Not $IncludeNonSDSGroups) {"+and+startswith(mailNickname,'Section_')"}) + "+and+resourceProvisioningOptions/Any(x:x+eq+'Team')&$groupSelectClause"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be made easier to read. Either:
$initialSDSGroupUri = "https://graph.microsoft.com/beta/groups?$groupSelectClause&`$filter=groupTypes/any(c:c+eq+'Unified')+and+resourceProvisioningOptions/Any(x:x+eq+'Team')" + $(if(-Not $IncludeNonSDSGroups) {"+and+startswith(mailNickname,'Section_')"})

OR
$initialSDSGroupUri = "https://graph.microsoft.com/beta/groups?$groupSelectClause&`$filter=groupTypes/any(c:c+eq+'Unified')+and+resourceProvisioningOptions/Any(x:x+eq+'Team')"
if (-Not $IncludeNonSDSGroups) {
$initialSDSGroupUri = "$initialSDSGroupUri+and+startswith(mailNickname,'Section_')"
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pertinent part of this was to eliminate the inline, middle of the string if (-Not $includeNonSdsGroups) and make it a possible suffix, to limit the risk of the $select statement being ignored. Your new version still has the $filter at the start.

Teams Scripts/Add-GroupOwners-To-Teams.ps1 Outdated Show resolved Hide resolved
@@ -127,12 +130,19 @@ function PageAll-GraphRequest($initialUrl, $logFilePath) {

$groupSelectClause = "`$select=id,mailNickname,emailAddress,displayName,resourceProvisioningOptions"

function Check-Team($group) {
function Check-Team($IncludeNonSDSGroups, $group) {
if (($group.resourceProvisioningOptions -ne $null) -and $group.resourceProvisioningOptions.Contains("Team") -and $group.mailNickname.StartsWith("Section_")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to also remove the last filter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants